package com.ug_project.views

import android.content.Context

import android.util.AttributeSet
import androidx.constraintlayout.widget.ConstraintLayout
import me.ezitku.base.R

/**
 * Created by yeganaaa on 17-1-22.
 */

open class ConstraintLayout : ConstraintLayout, INew_ViewGroup {

    override var _font: String? = null

    override fun onFinishInflate() {
        super.onFinishInflate()
        this.font = this._font
    }

    constructor(context: Context) : super(context) {

        Initialize(context, null)
    }

    constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
        Initialize(context, attrs)
    }

    constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
        Initialize(context, attrs)
    }

//    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
//    constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
//        Initialize(context, attrs)
//    }

    private fun Initialize(_context: Context, attrs: AttributeSet?) {

        val attr = context.obtainStyledAttributes(attrs, R.styleable.UG_VIEW)
        val xmlFont = attr.getString(R.styleable.UG_VIEW_ug_font)
        _font = if (!xmlFont.isNullOrEmpty()) xmlFont else FONT_NAME
    }
}